package save;

import java.io.Serializable;
import java.util.LinkedList;

public class Performance implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 5977813475830427612L;
	
	private transient int timestep = 0;
	
	private LinkedList<PerformanceEvent> events = new LinkedList<PerformanceEvent>();
	
	
	
	public boolean handleTimestep() {
		
		if (events.isEmpty()) return false;
		
		while (!events.isEmpty() && events.getFirst().getTimestep() == timestep) {
			PerformanceEvent e = events.removeFirst();
			e.execute();
		}
		
		timestep++;
		return !events.isEmpty();
	}
	
	public void addEvent(PerformanceEvent e) {
		events.add(e);
	}

	public void unpack() {
		for (PerformanceEvent e : events) {
			e.unpack();
		}
		
	}
	
	
	

}
